#ifndef TextReader_First
#define TextReader_First
#ifdef __GNUG__
#pragma interface
#endif

#include "TextStyles.h"

class StyledText;
class RunArray;
class VObject;
class VisualMark;

//---- TextReader --------------------------------------------------------------

class TextReader : public Object {
public:
	MetaDef(TextReader);

	TextReader(StyledText *st, CharStyle *cs, ParaStyle *ps);
	~TextReader();
	void Flush();

	//---- contents
	void Append(byte b);
	void Append(const char *s, int len= -1);

	//---- character properties
	void SetFont(GrFont f);
	void SetSize(int s);
	void SetInk(Ink *i);
	void SetFace(GrFace fc, int b);
	void SetFace(GrFace fc);
	void ToggleFace(GrFace fc);

	GrFont GetFont();
	int GetSize();
	GrFace GetFace();
	Ink *GetInk();

	//---- paragraph properties
	void SetParaProp(TxtParaProp what, int value);
	void SetParaProp(ParaDesc &pd);

	//---- graphic items
	void InsertVObject(VObject *vop);
	void InsertVisualMark(VisualMark *vmp);

protected:
	void FlushParaProp();
	void FlushCharProp();

private:
	StyledText *st;
	RunArray *cstyles;
	RunArray *pstyles;
	int pos;
	int runlen;
	int paralen;
	bool flushed;
		
	GrFace face;
	GrFont font;
	Ink *ink;
	int size;

	ParaDesc paraProp;
};

inline GrFont TextReader::GetFont()
	{ return font; }

inline int TextReader::GetSize()
	{ return size; }

inline GrFace TextReader::GetFace()
	{ return face; }

inline Ink *TextReader::GetInk()
	{ return ink; }

#endif

